package com.example.client;

import com.example.entity.TOrder;
import com.hzit.util.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import java.util.List;

@Component
@Slf4j
public class OrderClientFactory implements FallbackFactory<OrderClient> {

    @Override
    public OrderClient create(Throwable t) {
        return new OrderClient() {
            @Override
            public R<List<TOrder>> list() {
                log.info("访问订单列表失败，原因事：",t.getMessage());
                return R.fail("访问订单列表失败FallbackFactory，用于熔断处理!");
            }

            @Override
            public R add(TOrder order) {
                return null;
            }

            @Override
            public R update(TOrder order) {
                return null;
            }

            @Override
            public R delete(Integer id) {
                return null;
            }

            @Override
            public R getPort() {
                log.info("访问用户端口失败，原因事：",t.getMessage());
                return R.fail("访问用户服务端口失败FallbackFactory！");
            }
        };
    }
}